Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deny unused results #1825

Merged

Conversation

MichaelScofield
Copy link
Collaborator

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

The rustc lint: "deny unused-results" can check whether a return value is handled or not.

Pros to this lint: force people to deal with all return values, reduce the possibility of lurked bugs. Cons: sometimes could be annoying, even the most trivial return values (HashMap::insert for example) have to be dealt with.

According to our internal poll to date (positive 4, neutral 4, negative 0), we decide to enable it.

This PR goes through all our codes and fix all the warnings. Mainly:

  • use let _ = ...
  • use HashMap::from where possible
  • assert!(result.is_ok()) instead of result.unwrap()

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.

Refer to a related PR or issue link (optional)

@codecov
Copy link

codecov bot commented Jun 25, 2023

Codecov Report

Merging #1825 (4e9a76f) into develop (dcfce49) will decrease coverage by 0.30%.
The diff coverage is 88.94%.

@@             Coverage Diff             @@
##           develop    #1825      +/-   ##
===========================================
- Coverage    86.51%   86.22%   -0.30%     
===========================================
  Files          587      587              
  Lines        95642    95607      -35     
===========================================
- Hits         82745    82434     -311     
- Misses       12897    13173     +276     

Copy link
Contributor

@evenyag evenyag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lint is too verbose. Could we add #[must_use] to methods that need this check instead?

https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute

src/catalog/src/helper.rs Show resolved Hide resolved
src/catalog/src/local/memory.rs Outdated Show resolved Hide resolved
@evenyag
Copy link
Contributor

evenyag commented Jun 26, 2023

  • assert!(result.is_ok()) instead of result.unwrap()

I still prefer using unwrap() as it yields the error message. Assertion on is_ok() only tells us there is an error.

Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@killme2008 killme2008 merged commit fcff66e into GreptimeTeam:develop Jun 27, 2023
@MichaelScofield MichaelScofield deleted the chore/deny-unused-results branch June 27, 2023 07:37
@waynexia waynexia mentioned this pull request Jun 30, 2023
2 tasks
paomian pushed a commit to paomian/greptimedb that referenced this pull request Oct 19, 2023
* chore: deny unused results

* rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants